#include <iostream>

using namespace std;

int size;

struct ratData {
	int bombValue;
	int maxX;
	int maxY;
	int popGrid[1025][1025];
};

ratData* populateData(void) {
	//Number of Scenarios
	int nDataSet;
	cin >> nDataSet;
	size = nDataSet;

	ratData* data = new ratData[nDataSet];

	for(int i=0;i<nDataSet;i++) {
		//Bomb Size for scenario i
		cin >> data[i].bombValue;

		//# Rat Populations
		int nRatPop;
		cin >> nRatPop;
		data[i].maxX = -1;
		data[i].maxY = -1;
		
		for(int j=0;j<nRatPop;j++) {
			int x;
			int y;
			int popSize;

			//X-Y Coordinate
			cin >> x >> y >> popSize;
			data[i].popGrid[x][y] = popSize;

			if(x > data[i].maxX)
				data[i].maxX = x;
			if(y > data[i].maxY)
				data[i].maxY = y;
		}
	}
	return data;
}


int main (void) {
	ratData* data = populateData();
	for(int i=0;i<size;i++) {
		int bombValue = data[i].bombValue;
		int bombRange = 2*bombValue+1;
		int maxSum = 0;
		int curSum = 0;
		int xMax = 0;
		int yMax = 0;

		for(int y=0;y<bombRange;y++)
			for(int x=0;x<bombRange;x++)
				curSum += data[i].popGrid[x][y];
		for(int y=0;y<1025-bombRange;y++) {
			int oldSum = curSum;
			for(int x=0;x<1025-bombRange;x++) {
				for(int z=0;z<bombRange;z++) {
					curSum -= data[i].popGrid[x][y+z];
					curSum += data[i].popGrid[x+bombRange][y+z];
				}
				if(curSum > maxSum) {
					maxSum = max(curSum, maxSum);
					xMax = x;
					yMax = y;
				}
			}
			curSum = oldSum;
			for(int z=0;z<bombRange;z++) {
				curSum -= data[i].popGrid[z][y];
				curSum += data[i].popGrid[z][y+bombRange];
			}
			if(curSum > maxSum) {
				maxSum = max(curSum, maxSum);
				xMax = 0;
				yMax = y;
			}
		}
		cout << xMax << " " << yMax << " " << maxSum << endl;
	}
	delete [] data;
	return 0;
}
